﻿@using ACGN.MVC.Models.Newsflashss;
@model NewsflashViewModel
    <form class="layui-form" id="frmAdd">
        <div class="layui-form layuimini-form"style="border:1px dashed;margin:50px 50px 50px 50px;padding-top:20px;">
            <div class="layui-form-item">
                <label class="layui-form-label" asp-for="NFName">
                </label>
                <div class="layui-input-block">
                    <input type="text" asp-for="NFName" required lay-verify="title" autocomplete="off" class="layui-input">
                    <span asp-validation-for="NFName" style="color: #F56C6C"></span>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" asp-for="NfTypeId">
                </label>
                <div class="layui-input-block">
                    <select asp-for="NfTypeId" asp-items="@ViewBag.NfTypeList">
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" asp-for="NFContent">
                </label>
                <div class="layui-input-block">
                    <input type="text" asp-for="NFContent" required lay-verify="title" autocomplete="off" class="layui-input">
                    <span asp-validation-for="NFContent" style="color: #F56C6C"></span>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </div>

    </form>
    @section Scripts{
        <script>
            layui.use(['form'], function () {
                var form = layui.form,
                    layer = layui.layer,
                    $ = layui.$;
                //监听提交事件sumbmit,*表示那个提交按钮，过滤器名
                form.on('submit(saveBtn)', function (data) {
                    var str = $("#frmAdd").serialize();//表单序列化
                    console.log(str);
                    //$.post(地址,向服务器传的参数,回调函数,返回值类型)
                    $.post("/Admin/NewsFlash/AddNews", str, function (re) {

                        parent.layer.msg("添加成功");//parent父窗体
                        parent.layui.$("#btnSearch").click();//调用你窗体中的查询按钮的单击事件实现，数据刷新
                        //当你在iframe页面关闭自身时
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    }, "text");
                    return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
                });
            });
        </script>
    }
